import { Form } from 'ant-design-vue'
import { ref } from 'vue'

const { useForm } = Form

export function useUserForm() {
  const show = ref(false)
  const loading = ref(false)
  const formModel = ref({
    nickName: '',
    deptId: '',
    phone: '',
    email: '',
    userName: '',
    password: '123456',
    sex: '',
    status: '0',
    postIds: [],
    roleIds: [],
    remark: ''
  } as ICreateUserDTO)
  const formRules = ref({
    nickName: [{ required: true, message: '用户昵称不能为空' }],
    userName: [{ required: true, message: '用户名称不能为空' }],
    password: [{ required: true, message: '用户密码不能为空' }]
  } as FormRules<ICreateUserDTO>)
  const formRef = useForm(formModel, formRules)

  return {
    show,
    loading,
    formModel,
    formRef
  }
}
